function replacespace(str)
{
	var temp_str;
	temp_str=str.replace(" ","");
	return temp_str
}

function Jtrim(str)
{
        var i = 0;
        var len = str.length;
        if ( str == "" ) return( str );
        j = len -1;
        flagbegin = true;
        flagend = true;
        while ( flagbegin == true && i< len)
        {
           if ( str.charAt(i) == " " )
                {
                  i=i+1;
                  flagbegin=true;
                }
                else
                {
                        flagbegin=false;
                }
        }

        while  (flagend== true && j>=0)
        {
			if (str.charAt(j)==" ")
				{
						j=j-1;
						flagend=true;
				}
				else
				{
						flagend=false;
				}
        }

        if ( i > j ) return ("")

        trimstr = str.substring(i,j+1);
        return trimstr;
}


function oUrl(x){
	var returnStr = "";
	for(var i = 0; i < x.length; i ++)
	{
		returnStr += escape(x.charAt(i));
	}
	return returnStr;
}


function Hotel_City_Select(){
	var Hotel_City = $("Hotel_City").value;
	if (Hotel_City != ''){
		if (Jtrim(Hotel_City) == "")
			return (false);
		else{
			Hotel_City = oUrl(Hotel_City);
			var url = 'Change_City.asp?City_Name='+Hotel_City+'';
			var myAjax = new Ajax.Request(
                    url,
                    {
					method: 'get',
					onComplete: showResponse
					}
                    );
		}
	}
}


function showResponse(originalRequest)		
{
	//解析字符串
	BuildSel(originalRequest.responseText,document.getElementById("Hotel_Area"))

}

function BuildSel(str,sel)
{
		
	/*
	*--------------- BuildSel(str,sel) -----------------
	* BuildSel(str,sel) 
	* 功能:通过str构建Select.
	* 参数:str,字符串,由服务端返回的.有特定结构"字符串1|,字符串2,字符串3"
	*          也可为"字符串1序号|字符串1文本,字符串2序号|字符串2文本,字符串3序号|字符串3文本",如本例
	* 参数:sel,要构建的Select
	* 实例:BuildSel(unescape(oBao.responseText),document.all.sel2)
	*--------------- BuildSel(str,sel) -----------------
	*/
	//先清空原来的数据.
	sel.options.length=0;
	var arrstr = new Array();
	arrstr = str.split("|");
	//开始构建新的Select.
	sel.options.add(new Option( "全部",""));  
	if(str.length>0)   
	{
		for(var i=0;i<arrstr.length;i++)
		{
			//分割字符串
			var subarrstr=new Array
			subarrstr=arrstr[i].split(",")
			//生成下级菜单
			sel.options.add(new Option(subarrstr[1],subarrstr[1])); 
		}
		sel.options[0].selected=true
	}

}